package com.examples.ry.graphics;

import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Cursor;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.ImageData;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

public class CursorImageCreate {

	public static void main(String[] args) {
		final Display display = new Display();
		final Shell shell = new Shell(display);
		shell.setSize(150, 150);

		ImageData imageData = new ImageData("yourFile.gif");
		RGB[] rgbs = imageData.getRGBs();
		Color[] colors = null;
		if (rgbs != null) {
			colors = new Color[rgbs.length];
			for (int i = 0; i < rgbs.length; ++i) {
				colors[i] = new Color(display, rgbs[i]);
				System.out.println("Colors ::" + colors[i]);
			}
		}

		Cursor cursor = new Cursor(display,
				new Image(display, "yourFile.gif").getImageData(), 0, 0);
		shell.setCursor(cursor);

		shell.open();
		while (!shell.isDisposed()) {
			if (!display.readAndDispatch())
				display.sleep();
		}
		cursor.dispose();
		display.dispose();
	}
}
